//
//  CartoonViewController.m
//  Newproject3
//
//  Created by rimi on 16/9/22.
//  Copyright © 2016年 Liang. All rights reserved.
//

#import "CartoonViewController.h"
#import "CartoonTableViewCell.h"
#import "IntrouduceViewController.h"
static NSString *const CellID = @"CartoonTableViewCell";
@interface CartoonViewController ()<UITableViewDelegate,UITableViewDataSource>
@property (nonatomic,strong) UITableView *cartoonTableView;
@end

@implementation CartoonViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self.view addSubview:self.cartoonTableView];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 5;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    CartoonTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellID];
    NSString *plistPath = [[NSBundle mainBundle] pathForResource:@"plistdemo2" ofType:@"plist"];
    self.arrayData = [[NSMutableArray alloc] initWithContentsOfFile:plistPath];
    cell.cartoonImage.image = [UIImage imageNamed:self.arrayData[indexPath.row][@"image"]];
    cell.cartoonLable.text = self.arrayData[indexPath.row][@"lable2"];
    cell.cartoonLable1.text = self.arrayData[indexPath.row][@"lable1"];
    return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    IntrouduceViewController *vc = [[IntrouduceViewController alloc] init];
    ((IntrouduceViewController *)vc).dic = self.arrayData[indexPath.row];
    [self.navigationController pushViewController:vc animated:YES];
}
- (UITableView *)cartoonTableView{
    if (!_cartoonTableView) {
        _cartoonTableView = [[UITableView alloc] initWithFrame:self.view.frame];
        _cartoonTableView.rowHeight = 100;
        _cartoonTableView.delegate = self;
        _cartoonTableView.dataSource = self;
        [_cartoonTableView registerNib:[UINib nibWithNibName:@"CartoonTableViewCell" bundle:nil] forCellReuseIdentifier:CellID];
    }
    return _cartoonTableView;
}

@end
